/**
 created by xwy 2018/4/24 15:14
 user: 13720092498@163.com
 **/

const express = require('express')
const router = express.Router()
const db = require('../../db')
const crypto = require('crypto')

router.post('/loginForm', (req, res) => {
  const md5 = crypto.createHash('ms5')
  const loginmsg = req.body
  const phone = loginmsg.phone
  const pwd = md5.update(loginmsg.password).digest('hex')

  let p = new Promise((resolve, reject) => {
      db('select id, name from xsspt where phone = "' + phone + '" and pass = "' + pwd + '"', (err, data) => {
        data ? resolve(data) : reject(err)
      })
  })
JSON.stringify()
  // 0用户不存在，1登陆成功， 2登陆失败
  p.then((data) => {
    const len = data.length
    console.log(data)
  })
})
